package com.mybatis_puls.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.mybatis_puls.demo.entity.School;
import com.mybatis_puls.demo.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小🌤
 * @since 2020-12-16
 */
@RestController
@RequestMapping("/school")
public class SchoolController {

     @Autowired
    private SchoolService schoolService;


     @RequestMapping("/save")
    public Object save (School school){
          schoolService.save(school);
          return school;
     }
    @RequestMapping("/info")
    public Object save (String name){
         QueryWrapper<School> wrapper=new QueryWrapper<>();

        if(name!=null||name.equals("")){
            wrapper.like("name",name);
        }
        List<School> list = schoolService.list(wrapper);
        return list;
    }
}

